]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspace: Use generic _addWindow function to add new clones
authorJonas Dreßler <verdre@v0yd.nl>
Sun, 31 May 2020 21:15:06 +0000 (23:15 +0200)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Thu, 4 Jun 2020 17:40:09 +0000 (17:40 +0000)
Now that we handle all ClutterClones belonging to the WindowClone pretty
much the same, we can add a generic _addWindow function to WindowClone
which creates the ClutterClone and adds it to the layout manager.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1297

js/ui/workspace.js

index d58114dfce6c63f2f2e41b17c54fd1450cb1ac6c..859e579bbb14532420f4c39b61d1627c624f0e3f 100644 (file)
@@ -182,14 +182,6 @@ var WindowClone = GObject.registerClass({
         this.metaWindow._delegate = this;
         this._workspace = workspace;
 
-        this._windowClone = new Clutter.Clone({ source: realWindow });
-        // We expect this to be used for all interaction rather than
-        // this._windowClone; as the former is reactive and the latter
-        // is not, this just works for most cases. However, for DND all
-        // actors are picked, so DND operations would operate on the clone.
-        // To avoid this, we hide it from pick.
-        Shell.util_set_hidden_from_pick(this._windowClone, true);
-
         // The MetaShapedTexture that we clone has a size that includes
         // the invisible border; this is inconvenient; rather than trying
         // to compensate all over the place we insert a ClutterActor into
@@ -203,7 +195,7 @@ var WindowClone = GObject.registerClass({
 
         this.set_offscreen_redirect(Clutter.OffscreenRedirect.AUTOMATIC_FOR_OPACITY);
 
-        this.layout_manager.addWindow(this._windowClone, this.metaWindow);
+        this._addWindow(realWindow.meta_window);
 
         this._delegate = this;
 
@@ -242,6 +234,20 @@ var WindowClone = GObject.registerClass({
         this._closeRequested = false;
     }
 
+    _addWindow(metaWindow) {
+        const windowActor = metaWindow.get_compositor_private();
+        const clone = new Clutter.Clone({ source: windowActor });
+
+        // We expect this to be used for all interaction rather than
+        // the ClutterClone; as the former is reactive and the latter
+        // is not, this just works for most cases. However, for DND all
+        // actors are picked, so DND operations would operate on the clone.
+        // To avoid this, we hide it from pick.
+        Shell.util_set_hidden_from_pick(clone, true);
+
+        this.layout_manager.addWindow(clone, metaWindow);
+    }
+
     vfunc_has_overlaps() {
         return this.hasAttachedDialogs();
     }
@@ -278,7 +284,7 @@ var WindowClone = GObject.registerClass({
 
         // Display dialog if it is attached to our metaWindow
         if (win.is_attached_dialog() && parent == this.metaWindow)
-            this._doAddAttachedDialog(win, win.get_compositor_private());
+            this._addWindow(win);
 
         // The dialog popped up after the user tried to close the window,
         // assume it's a close confirmation and leave the overview
@@ -290,14 +296,6 @@ var WindowClone = GObject.registerClass({
         return this.get_n_children() > 1;
     }
 
-    _doAddAttachedDialog(metaWin, realWin) {
-        let clone = new Clutter.Clone({ source: realWin });
-
-        Shell.util_set_hidden_from_pick(clone, true);
-
-        this.layout_manager.addWindow(clone, metaWin);
-    }
-
     _updateAttachedDialogs() {
         let iter = win => {
             let actor = win.get_compositor_private();
@@ -307,7 +305,7 @@ var WindowClone = GObject.registerClass({
             if (!win.is_attached_dialog())
                 return false;
 
-            this._doAddAttachedDialog(win, actor);
+            this._addWindow(win);
             win.foreach_transient(iter);
             return true;
         };